package cn.nanmeishu;

/**
 * 堆溢出异常实例
 */
public class Model1 {
    static class OOMDemo{

    }

    /**
     * 设置jvm 参数
     * -Xms20m -Xmx20m -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=D:\heap_dump.hprof
     * @param args
     */
    public static void main(String[] args) {
        OOMDemo[] oomDemos=new OOMDemo[1000000];
        for (int i = 0; i < oomDemos.length; i++) {
            System.out.println(i);
            oomDemos[i]=new OOMDemo();
        }
    }
}
